<?php
namespace Home\Controller;
class GiftsController extends CommonController {

    public function index() {
        $cats = getDictionary('gifts_cat', 0);
        $gifts = getTableFile('gifts');
        foreach($cats as $k=>$v){
            foreach($gifts as $v2){
              if($v['id'] == $v2['pid']){
                     $cats[$k]['sub'][] = $v2;
                }
            }
        }
        $this->assign("cats", $cats);
        $this->assign("ctitle", "积分商城");
        $this->display("Index:gifts");
    }

    public function award() {
        $user = M("user")->field("money")->where("id = " . session("userid") . "")->find();
        $lists = getTableFile('award');
        foreach($lists as $k=>$v){
            $lists[$k]['pic'] = C('picFile').$v['pic'];
        }
        $this->assign("user", $user);
        $this->assign("lists", $lists);
        $this->assign("ctitle", "积分抽奖");
        $this->display("Index:award");
    }
   

}